/*
=======================================================================

  BOTS Infiltrator Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_INFILTRATOR_STEAL			1
#define BOTS_INFILTRATOR_TEAM_DISGUISE	3
#define BOTS_INFILTRATOR_ENEMY_DISGUISE	4

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	steal;
  menutext_s	team_disguise;
  menutext_s	enemy_disguise;
  menutext_s	cancel;
} infiltratorCommands_t;

static infiltratorCommands_t		s_infiltrator;

/*
=================
BOTS_InfiltratorCommandsMenu_Event
callback routine
=================
*/
void BOTS_InfiltratorCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_INFILTRATOR_STEAL:
		trap_Cmd_ExecuteText( EXEC_APPEND, "steal\n" );
		break;
	case BOTS_INFILTRATOR_TEAM_DISGUISE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "team_disguise\n" );
		break;
	case BOTS_INFILTRATOR_ENEMY_DISGUISE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "enemy_disguise\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_InfiltratorCommandsMenu_Init
=================
*/
void BOTS_InfiltratorCommandsMenu_Init() 
{
	int y;

	memset( &s_infiltrator, 0 ,sizeof(infiltratorCommands_t) );
	s_infiltrator.menu.wrapAround = qtrue;
	s_infiltrator.menu.fullscreen = qfalse;

	y = 96;
	s_infiltrator.title.generic.type	= MTYPE_PTEXT;
	s_infiltrator.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_infiltrator.title.generic.x		= 320;
	s_infiltrator.title.generic.y		= y;
	s_infiltrator.title.string			= "INFILTRATOR COMMANDS MENU";
	s_infiltrator.title.color			= color_bots_menu;
	s_infiltrator.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_infiltrator.steal.generic.type		= MTYPE_PTEXT;
	s_infiltrator.steal.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_infiltrator.steal.generic.x			= 320;
	s_infiltrator.steal.generic.y			= y;
	s_infiltrator.steal.generic.id			= BOTS_INFILTRATOR_STEAL;
	s_infiltrator.steal.generic.callback	= BOTS_InfiltratorCommandsMenu_Event; 
	s_infiltrator.steal.string				= "TOGGLE STEALING - steal";
	s_infiltrator.steal.color				= color_bots_menu;
	s_infiltrator.steal.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_infiltrator.team_disguise.generic.type		= MTYPE_PTEXT;
	s_infiltrator.team_disguise.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_infiltrator.team_disguise.generic.x			= 320;
	s_infiltrator.team_disguise.generic.y			= y;
	s_infiltrator.team_disguise.generic.id			= BOTS_INFILTRATOR_TEAM_DISGUISE;
	s_infiltrator.team_disguise.generic.callback	= BOTS_InfiltratorCommandsMenu_Event; 
	s_infiltrator.team_disguise.string				= "TEAM DISGUISE - team_disguise";
	s_infiltrator.team_disguise.color				= color_bots_menu;
	s_infiltrator.team_disguise.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 1) {
		s_infiltrator.team_disguise.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_infiltrator.enemy_disguise.generic.type		= MTYPE_PTEXT;
	s_infiltrator.enemy_disguise.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_infiltrator.enemy_disguise.generic.x			= 320;
	s_infiltrator.enemy_disguise.generic.y			= y;
	s_infiltrator.enemy_disguise.generic.id			= BOTS_INFILTRATOR_ENEMY_DISGUISE;
	s_infiltrator.enemy_disguise.generic.callback	= BOTS_InfiltratorCommandsMenu_Event; 
	s_infiltrator.enemy_disguise.string				= "ENEMY DISGUISE - enemy_disguise";
	s_infiltrator.enemy_disguise.color				= color_bots_menu;
	s_infiltrator.enemy_disguise.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 2) {
		s_infiltrator.enemy_disguise.generic.flags |= QMF_GRAYED;
	}

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_infiltrator.cancel.generic.type		= MTYPE_PTEXT;
	s_infiltrator.cancel.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_infiltrator.cancel.generic.x			= 320;
	s_infiltrator.cancel.generic.y			= y;
	s_infiltrator.cancel.generic.id			= BOTS_CANCEL;
	s_infiltrator.cancel.generic.callback	= BOTS_InfiltratorCommandsMenu_Event; 
	s_infiltrator.cancel.string				= "CANCEL";
	s_infiltrator.cancel.color				= color_bots_menu;
	s_infiltrator.cancel.style				= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_infiltrator.menu, &s_infiltrator.title );
	Menu_AddItem( &s_infiltrator.menu, &s_infiltrator.steal );
	Menu_AddItem( &s_infiltrator.menu, &s_infiltrator.team_disguise );
	Menu_AddItem( &s_infiltrator.menu, &s_infiltrator.enemy_disguise );
	Menu_AddItem( &s_infiltrator.menu, &s_infiltrator.cancel );
}

void BOTS_InfiltratorCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_InfiltratorCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_infiltrator.menu );
}
